#ifndef _PID_H   
#define _PID_H

#include "main.h"
#include "stm32f4xx_hal.h"
#include "stm32f4xx_hal_tim.h"
#include "stm32f4xx_hal_gpio.h"

typedef struct
{
    float target_val;//目标值
    float actual_val;//实际值
    float err;//当前偏差
    float err_last;//上次偏差
    float err_sum;//误差累计值
    float Kp,Ki,Kd;//比例，积分，微分系数
} tPid;

//声明函数
float P_realize(tPid * pid,float actual_val);
float PI_realize(tPid * pid,float actual_val);
float PID_realize(tPid * pid,float actual_val);

void pid_init(void);
void ABcatch_crol(void);
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
#endif
